<template>
	<view class="selftesting">
		<view class="selftesting_item" v-for="(item, index) in questionList" :key="index" @click="gotoday(item, index)">
			<view class="selftesting_itemmin">
				<view class="selftesting_itemmintitle">{{ item.title }}</view>
				<view class="selftesting_itemtime">{{ item.create_time }}</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			questionList: [],
			index: 0
		};
	},
	mounted() {
		this.lnformation();
	},
	methods: {
		//获取试题自测列表
		lnformation() {
			const request = this.$http({
				url: 'question/questionList?pageNo=' + 1 + '&pageSize=' + 10000,
				method: 'POST'
			}).then(res => {
				this.questionList = res.data.records;
				this.questionList.forEach(item => {
					this.$set(item, 'index', this.index++);
					console.log(this.questionList, '新数据');
				});
				uni.setStorageSync('questionList', this.questionList);

				console.log(res, '++++');
			});
			return request;
		},
		gotoday(item, index) {
			console.log(item, '+++++');
			uni.navigateTo({
				url: '../../subpkg/questions/index?item=' + JSON.stringify(item) + '&index=' + index
			});
		}
	},
	// 下拉刷新
	onPullDownRefresh() {
		(this.questionList = []),
			this.lnformation().finally(() => {
				uni.stopPullDownRefresh();
			});
	}
};
</script>

<style lang="scss">
.selftesting {
	padding: 32rpx;

	.selftesting_item {
		margin-top: 24rpx;
		background: #ffffff;
		box-shadow: 0px 10rpx 20rpx 0px rgba(29, 82, 130, 0.06);
		border-radius: 16rpx;
		.selftesting_itemmin {
			padding: 24rpx;
			.selftesting_itemmintitle {
				text-overflow: -o-ellipsis-lastline;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				line-clamp: 2;
				-webkit-box-orient: vertical;
				font-size: 32rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #2a3447;
			}
			.selftesting_itemtime {
				margin-top: 25rpx;
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #7b7e8f;
			}
		}
	}
	.selftesting_item:first-child {
		margin-top: 0;
	}
}
</style>
